


/*
*递归
* 2.方法内部自己调用自己
* 3.有趋近于终止的条件
*
* */

import java.util.Scanner;

public class Test {





    /*
    *斐波那契数列
    * fib(n) = fib(n-1) + fib(b-2)
    *
    *
    *  */

    //递归浪费时间 最好使用循环（迭代）
    public static int fib(int n) {
        if(n == 1 || n == 2) {
            return 1;
        }
        int tmp = fib(n-1) + fib(n-2);
        return tmp;
    }
    public static int fib2(int n) {
        if(n == 1 || n == 2) {
            return 1;
        }
        int f1 = 1;
        int f2 = 1;
        int f3 = 0;
        for (int i = 3; i <= n ; i++) {
            f3 = f1 + f2;
            f1 = f2;
            f2 = f3;
        }
        return f3;
    }




    public static int func2(int n) {
        if(n < 10) {
            return n;
        }else {

            return func2(n/10) + n % 10;
        }
    }

    public static void main4(String[] args) {
        System.out.println(func2(1234));
    }
    public static int add(int n) {
        if(n == 1) {
            return 1;
        }else {
            int sum = n + add(n-1);
            return sum;
        }
    }

    public static void main3(String[] args) {
        System.out.println(add(10));
    }
    public static void print(int n) {
        if(n < 10){
            System.out.println(n);
        }else {
            print(n/10);
            System.out.print(n%10 + " ");
        }


    }
    public static void main2(String[] args) {

        print(1234);
    }
    public static int func(int n) {
        if(n == 1){
            return 1;
        }
        return n*func(n - 1);
    }
    public static void main1(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int ret = func(n);
        System.out.println(ret);
    }


}
